import threading
from messageloop import messageloop

if __name__ == "__main__":
    if __name__ == "__main__":
        print("[%d] Hello MessageLoop" % (threading.get_ident()))
        x = 1
        y = 2

        loop = messageloop.MessageLoop()


        def run():
            loop.loop(0)


        thread = threading.Thread(target=run)
        thread.start()


        def task():
            print("[%d] task result %d" % (threading.get_ident(), x + y))

        loop.post(task)
        loop.quit()
        thread.join()
        print("[%d] Main thread quit" % (threading.get_ident()))